package loyaltypartner.service;

import java.util.Map;

import loyaltypartner.dao.PaybackDAO;

@SuppressWarnings("serial")
public class EnrollMemberServlet extends AbstractPaybackServlet 
{
	@Override
	protected Object getBusinessMethod(Map<String, String[]> params)
	{
		String result = "Invalid parameters";
		
		String[] firstName = params.get("firstName");
		String[] lastName = params.get("lastName");
		String[] PIN = params.get("PIN");
		String[] email = params.get("email");
		String[] phoneNumber = params.get("phoneNumber");
		
		if(firstName!=null && firstName.length>0 && lastName!=null && lastName.length>0 && PIN!=null && PIN.length>0 && email!=null && email.length>0 && phoneNumber!=null && phoneNumber.length>0)
			result=PaybackDAO.fetchDAO().createNewMember(firstName[0], lastName[0], PIN[0], email[0], phoneNumber[0]).getMemberID();
		
		return result;
	}
}
